package main;

import common.network.eolo.EoloURL;
import common.props.ProjProps;

import dataset.DataSetInterface;
import dataset.eolo.EoloData;

public class DataController {
	private String myURL=null;
	private EoloURL eo=null;
	private DataSetInterface mainDataSet = null;
	private boolean isOK;
	private int refreshtime;
	
	public boolean isOK() {
		return isOK;
	}

	public DataController() throws Exception{
		isOK = false;
		initialize();
	}
	
	private void initialize() throws Exception {
		myURL=ProjProps.getProp(ProjProps.WIND_DATA_URL);
		eo = new EoloURL(myURL);
		mainDataSet = new EoloData(eo);
		mainDataSet.refreshWindData();
		try {
			refreshtime = new Integer(ProjProps.getProp(ProjProps.DATA_REFRESH_TIME)).intValue()*60*1000;
		} catch (NumberFormatException e) {
			refreshtime = RefreshThread.DEFAULT_REFRESHTIME;
		}
		isOK = true;
	}

	public DataSetInterface getMainDataSet() {
		return mainDataSet;
	}
	
	public void refreshDataSet() throws Exception{
		mainDataSet.refreshWindData();
	}

	public int getRefreshtime() {
		return refreshtime;
	}
}
